package class202204._21_25;
class Cat{
    //这些被private修饰的属性  或者  方法  只能在当前Cat中被使用  安全 类外不可见
    private String name;
    public int age;
    public   String color;


    public void setName(String name){
        this.name = name;
    }

    public String getName(){
        return this.name;
    }

    public Cat(String name, int age, String color) {
        this.name = name;
        this.age = age;
        this.color = color;
    }
    public Cat(){
        System.out.println("不带参数的构造方法");
    }
    public void eat(){
        System.out.println(this.name+"正在吃饭！");
    }
    public void sleep(){
        System.out.println(this.name+"正在睡觉！");
    }
    public void show(){
        System.out.println("姓名："+this.name+"年龄："+this.age+"颜色："+this.color);
    }

    @Override
    public String toString() {
        return "Cat{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", color='" + color + '\'' +
                '}';
        //return "zhanhwei is cool";
    }

    public void mew() {
    }
}
public class TestDemo3 {
//==========类的调用者==============================================
    public static void main(String[] args) {
        Cat cat3 = new Cat();
        //cat3.name = "嘻嘻";
        cat3.setName("嘻嘻");
        String name = cat3.getName();
        System.out.println(name);
        cat3.age = 10;
        cat3.color = "黄色";
        System.out.println(cat3);
    }




    public static void main2(String[] args) {
        Cat cat3 = new Cat();
        //cat3.show();
        Cat cat = null;
        System.out.println(cat3);
    }





    public static void main1(String[] args) {
        Cat cat = new Cat("xuanxuan ",4 , " 橘黄色");
        cat.show();
        cat.sleep();
        Cat cat2 = new Cat("xuanxuan ",14 , " 橘黄色1");
        cat2.show();
        cat2.sleep();

        Cat cat3 = new Cat();
        cat3.show();
        cat3.sleep();
    }
}
